package com.enotary.flutter_obs;

import android.os.Looper;
import android.util.Log;

import java.io.Closeable;

public class ObsUtils {
    public static String LOG_TAG = "flutterObsLog";

    public static void logI(String msg) {
        if(BuildConfig.DEBUG) Log.i(LOG_TAG, msg);
    }
    /**
     * 是否主线程
     */
    public static boolean isMainThread(){
        boolean main = Thread.currentThread() == Looper.getMainLooper().getThread();
        ObsUtils.logI("current thread " + main);
        return main;
    }


    public static void close(Closeable closeable) {
        if(closeable == null) return;
        try {
            closeable.close();
        } catch (Exception e) {
            ObsUtils.logI(e.getMessage());
            e.printStackTrace();
        }
    }
}
